import { request } from "@/utils/request";
import type {
	LoginParams,
	RegisterParams,
	ForgotPasswordParams,
	LoginResult,
	UserInfo,
	PageParams,
	PageResult,
} from "@/types/user";
import type { RequestResultType } from "@/types";

export const REQUEST_LOGIN = (data?: LoginParams) => {
	return request.post<RequestResultType<LoginResult>>("/login", data);
};

export const getUserInfo = (data: LoginParams) => {
	return request.post<RequestResultType<LoginResult>>("/login", data);
};

export const register = (data: RegisterParams) => {
	return request.post<RequestResultType<{ message: string }>>("/register", data);
};

export const forgotPassword = (data: ForgotPasswordParams) => {
	return request.post<RequestResultType<{ message: string }>>("/forgot-password", data);
};

export const getUserList = (params: PageParams) => {
	return request.get<RequestResultType<PageResult<UserInfo>>>("/users", { params });
};
